angular.module('row-show', [])

.directive 'rowShow', ->
    restrict    : 'E'
    templateUrl : 'templates/row-show/row-show.html'
    scope:
        'items' : '=items'
        'headTitle' : '=headTitle'
        'showLength' : '=showLength'
    link: ($scope, $element, $attrs) ->
.controller 'rowShowCtrl', ($scope) ->
    _.extend $scope,
        if $scope.items.length <= 3
            $scope.showFooter = false
        else
            $scope.showFooter = true
            $scope.showMoreFlag = true
        showMore: ->
            $scope.tmp = $scope.showLength
            $scope.showLength =  $scope.items.length
            $scope.showMoreFlag = !$scope.showMoreFlag
        reset: ->
            $scope.showLength = $scope.tmp
            $scope.showMoreFlag = !$scope.showMoreFlag

